#!/bin/bash
# rt-migration
###SHELLPACK preamble rtmigration-bench v1.5

CYCLICTEST_BACKGROUND=none

###SHELLPACK parseargBegin
###SHELLPACK parseargInstall
###SHELLPACK parseargParam   --duration		RTMIGRATION_DURATION
###SHELLPACK parseargYes     --check		RTMIGRATION_CHECK
###SHELLPACK parseargEnd
###SHELLPACK monitor_hooks

###SHELLPACK check_external_install_required rttestbuild rttestbuild-${VERSION} ${VERSION}
###SHELLPACK init_complete

RTMIGRATION_CHECK_SWITCH=
if [ "$RTMIGRATION_CHECK" = "yes" ]; then
	RTMIGRATION_CHECK_SWITCH=-c
fi

cd $SHELLPACK_SOURCES/rttestbuild-${VERSION}-installed || die "Failed to change to rttest directory"

monitor_pre_hook $LOGDIR_RESULTS $P
echo Starting rt-migration threads
echo o rt-migrate-test $RTMIGRATION_CHECK_SWITCH -r $RTMIGRATION_DURATION
./rt-migrate-test $RTMIGRATION_CHECK_SWITCH	\
	-r $RTMIGRATION_DURATION		\
	> $LOGDIR_RESULTS/rtmigration.log
RET=$?
gzip $LOGDIR_RESULTS/rtmigration.log
monitor_post_hook $LOGDIR_RESULTS $P
if [ $RET -ne 0 ]; then
	exit $SHELLPACK_ERROR
fi
exit $SHELLPACK_SUCCESS
